<?php
namespace app\index\controller;
use think\Db;
class Information extends Base{
    public function information(){
        $type=input('get.type');
        if($type==2){
        	$type=2;
        	$fragment='inews';
        }else{
        	$type=1;
        	$fragment='cnews';
        }
        $map = [
            ['state', '=', 1]
        ];
        $param=request()->param();
        array_push($param,['type'=>$type]);
    	$news_type1=Db::name('news')->where($map)->where('type',1)->order('id desc')->paginate(2,false,['query' => $param,'fragment'=>$fragment]);
    	$news_type2=Db::name('news')->where($map)->where('type',2)->order('id desc')->paginate(2,false,['query' => $param,'fragment'=>$fragment]);
        $this->assign('system',$this->system_set());
        $this->assign('news_type1',$news_type1);
        $this->assign('news_type2',$news_type2);
        $this->assign('fragment',$fragment);
        $this->assign('type',$type);
        return $this->fetch();
    }
    public function cnews(){
        $map = [
            ['state', '=', 1],
            ['type', '=', 1]
        ];
    	$news_type1=Db::name('news')->where($map)->order('id desc')->paginate(6);
        $this->assign('system',$this->system_set());
        $this->assign('news_type1',$news_type1);
        return $this->fetch();
    }
    public function inews(){
        $map = [
            ['state', '=', 1],
            ['type', '=', 2]
        ];
    	$news_type2=Db::name('news')->where($map)->order('id desc')->paginate(6);
        $this->assign('system',$this->system_set());
        $this->assign('news_type2',$news_type2);
        return $this->fetch();
    }
    public function detail(){
    	$detail=Db::name('news')->where('id',input('get.id'))->find();
        $this->assign('system',$this->system_set());
        $this->assign('detail',$detail);
        return $this->fetch();
    }
}
